CONTENTS | INDEX | PREV | NEXT
 fputc
 putc

 NAME
  fputc - write a single character to a file pointer
  putc  - write a single character to a file pointer (MACRO)

 SYNOPSIS
  #include <stdio.h>

  int c = fputc(c, fp);
  int c = putc(c, fp);
  FILE *fp;

 FUNCTION
  [f]putc() writes a single character to a file pointer.  If all
  goes well the character is returned, else EOF is returned.

  fputc() is a function call while putc() is a macro

 NOTE
  refer to the file_pointer manual page for general information

 EXAMPLE
  /*
   *  copy stdin to stdout using fgetc/fputc.  Normally one uses
   *  fread/fwrite, but I'll save that for the fread manual page.
   *
   *  note that I output the initial message to stderr so it does
   *  not get stuck into stdout in case the user has redirected
   *  stdout.
   */

  #include <stdio.h>

  main()
  {
      int c;

      fputs("Type a couple of lines, then ^ (EOF)n", stderr);
      while ((c = fgetc(stdin)) != EOF) {
      fputc(c, stdout);
      }
      return(0);
  }

 INPUTS
  int c;      character to write
  FILE *fp;   file pointer

 RESULTS
  int c;      character written (same as first argument) or EOF
          if error.

 SEE ALSO
  getc, putc, fputc, fread, fwrite, puts, fputs, gets, fgets